package de.hochschuletrier.bachelor.antfarm.entity;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.GameContainer;

import de.hochschuletrier.bachelor.antfarm.util.AssetManager;
import de.hochschuletrier.bachelor.antfarm.util.assets.AssetImage;
import de.hochschuletrier.bachelor.antfarm.world.World;

public class Foodsource extends Entity {
	private int amountOfPieces;
	private List<Foodpiece> pieces;

	public Foodsource(int x, int y, int amountOfPieces) {
		super("Futterquelle", x, y, AssetManager.getInstance().getImage(AssetImage.foodSource));
		this.amountOfPieces = amountOfPieces;
		
		pieces = new ArrayList<Foodpiece>();
		for (int i=0;i<amountOfPieces;++i) {
			pieces.add(new Foodpiece(this, 1));
		}
	}

	public Foodpiece takeFoodpiece() {
		Foodpiece piece = pieces.get(0);
		amountOfPieces--;
		if (amountOfPieces <= 0) {
			dispose();
		}
		pieces.remove(piece);
		return piece;
	}

	public void dispose() {
		World.getInstance().removeEntity(this);
	}

	public List<Foodpiece> getFoodpieces() {
		return pieces;
	}

	public int getAmountOfFoodpieces() {
		return pieces.size();
	}

	@Override
	public void update(GameContainer gc, int delta) {
		// TODO Auto-generated method stub
		
	}
}
